package com.lunwen.view;

import com.lunwen.view.component.Context;
import com.lunwen.view.component.MeFrame;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MeControl extends Context {

    private JLabel name = new JLabel("用户名");
    private JButton modify = new JButton("修改密码");
    private JButton exit = new JButton("退出登录");

    public MeControl(LoginFrame loginFrame, MeFrame me) {
        super(100, 300);

        name.setBounds(0,30,100,48);
        this.add(name,20);

        modify.setBounds(0,100,100,48);
        this.add(modify,20);

        exit.setBounds(0,170,100,48);
        this.add(exit,20);

        exit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                me.dispose();
                loginFrame.setVisible(true);
            }
        });
        modify.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new ModifyPassFrame().setVisible(true);
            }
        });

    }

    public void setName(String name) {
        this.name.setText(name);
    }

    public String getLoginName() {
        return name.getText();
    }

}
